<template>
  <div class="rightItem">
    <div class="title">
      参考资料
    </div>
    <div class="panel">
      <div class="left-item" v-for="(item,index) in data" :key="index">
        <div class="img">
          <img src="@/assets/img/pdf.png" alt="" v-if="item.imagetype == '.pdf'">
          <img src="@/assets/img/video.png" alt="" v-else-if="item.imagetype == '.mp4'">
          <img src="@/assets/img/image.png" alt="" v-else-if="item.imagetype == '.jpg' || item.imagetype == '.jpeg' || item.imagetype == '.png'">
          <img src="@/assets/img/zip.png" alt="" v-else-if="item.imagetype == '.zip' || item.imagetype == '.rar'">
          <img src="@/assets/img/word.png" alt="" v-else-if="item.imagetype == '.docx' || item.imagetype == '.pub' || item.imagetype == '.pptx'">
          <img src="@/assets/img/file.png" alt="" v-else>
        </div>
        <div class="ma-left">
          <a :href="item.url" class="color">
            <div class="titles">{{item.title}}</div>
          </a>
          <div class="rigth">
            <div class="d-fix">
              <div class="download" @click="downloadFile(item.url)">下载</div>
            </div>
            <div class="d-time">{{item.ctime}}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'referenceMaterial',
    components: {},
    props: {
      data: {
        type: Array ,
        default: null
      }
    },
    emits: ["downloadfile"],
    setup(props,context){
      const downloadFile = (res) => {
        context.emit("downloadfile",res)
      }
      return {
        downloadFile
      }
    }
  }
</script>
<style lang="scss" scoped>
  .rightItem {
    background-color: #fff;
    flex: 3;
    display: flex;
    flex-direction: column;
    margin-bottom: 24px;
    // align-items: center;
    &:nth-child(3){
      flex: 2.5;
      margin-bottom: 0px;
    }

    &:nth-child(1) .panel{
      display: flex;
      justify-content: center;
      align-items: center;
      height: calc(100% - 55px);
      .panelBox{
        display: flex;
        flex-wrap: wrap;
        width: 60%;
        .fix {
          flex: 33% !important;
        }
        .item{
          flex: 100%;
          display: grid;
          place-items: center;
          cursor: pointer;
          margin-bottom: 10px;
          margin-top: 20px;
          img{
            width: 26px;
            height: 26px;
          }
          p{
            color: #00000073;
            font-size: 14px;
          }
        }
      }

    }

    &:nth-child(2) .panel,&:nth-child(3) .panel{
      margin: 10px;
      .item {
        display: flex;
        align-items: center;
        font-size: 14px;
        .img {
          width: 30px;
          height: 24px;
          border-radius: 50%;
          img{
            width: 100%;
            height: 100%;
          }
        }

        p {
          margin-left: 20px;
          flex: 1;
          color: #444444FF;
        }

        span {
          color: #888888FF;
          margin-right: 20px;
        }
      }
    }


    .title {
      border-bottom: 1px solid #E9E9E9;
      padding-left: 24px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 16px;
      height: 55px !important;
    }

  }
  .left-item {
    display: flex;
    padding-bottom: 15px;
    padding-top: 10px;
    border-bottom: 1px solid #efeeee;
  }
  .ma-left {
    margin-left: 15px;
  }
  .download {
    border: 1px solid;
    padding: 5px;
    border-radius: 5px;
    background: #409eff;
    color: white !important;
    margin-right: 1px !important;
    cursor:pointer;
    height: 18px;

  }
  .download:active {
    color: red !important;
  }
  .wj {
    padding:20px;
    font-size: 12px;
  }
  .img {

  }
  .d-time {
    color: #888888FF;
    padding-top: 5px;
  }
  .color {
    color: #444444;
    width: 100px;
  }
  .titles {
    width: 400px;
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .rigth {
    display: flex;
    margin-top: 5px;
    justify-content: space-between;
  }
  .d-fix {
    display: flex;
  }
  .img img {
    width: 55px !important;
    height:55px !important;
  }
</style>
